package cn.gov.lyhdga.first.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import cn.gov.lyhdga.first.entity.Message;

public interface MessageDao extends PagingAndSortingRepository<Message, Long>, JpaSpecificationExecutor<Message> {
	
	Page<Message> findByUserId(Long id, Pageable pageRequest);
	
	@Modifying
	@Query("delete from Message mes where mes.user.id = ?1")
	void deleteByUserId(Long id);

}
